package com.bawei.module_home

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.alibaba.android.arouter.facade.annotation.Route
import com.bawei.library_base.AppManager
import com.bawei.library_common.arouter.ARouterFragmentPath
import com.bawei.library_common.mvvm.BaseFragment
import com.bawei.module_home.adapter.HomeFragmentPageAdapter
import com.bawei.module_home.daily.DailyFragment
import com.bawei.module_home.databinding.HomeFragmentHomeBinding
import com.bawei.module_home.discovery.DiscoveryFragment
import com.bawei.module_home.nominate.NominateFragment

@Route(path = ARouterFragmentPath.PAGER_HOME)
class HomeFragment : BaseFragment<HomeFragmentHomeBinding>() {
    private lateinit var list:ArrayList<Fragment>
    private lateinit var homeFragmentPageAdapter: HomeFragmentPageAdapter


    override fun getLayout(): Int {
        return R.layout.home_fragment_home

    }

    override fun initData() {
        list = ArrayList<Fragment>()
        list.add(DiscoveryFragment())
        list.add(NominateFragment())
        list.add(DailyFragment())
        homeFragmentPageAdapter = HomeFragmentPageAdapter(list,childFragmentManager,
            FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)
        viewDataBinding.vpHomeContent.adapter = homeFragmentPageAdapter
        viewDataBinding.tabLayout.setupWithViewPager(viewDataBinding.vpHomeContent)//上下联动



        AppManager.getActivity("com.bawei.module_main.ui.SplashActivity")
    }

    override fun initListener() {

    }


}